package com.neu.his.home.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.his.commonutils.R;
import com.neu.his.home.entity.schTimeVo;
import com.neu.his.home.service.HomeService;

@RestController
@CrossOrigin
@RequestMapping("/his/home")
public class HomeController {
	@Autowired
	private HomeService homeService;
	@GetMapping("/showData")
	public R showData() {
		List<schTimeVo> stalist = homeService.getShowData();
		
		List<String> date_calculatedList = new ArrayList<>();
	    List<Integer> numDataList = new ArrayList<>();
	    for (int i = 0; i < stalist.size(); i++) {
	    	schTimeVo daily = stalist.get(i);
	        //封装日期list集合
	    	date_calculatedList.add(daily.getSchedDate());
	    	numDataList.add(daily.getCount());
	    }
	    Map<String, Object> map =new HashMap<>();
	    map.put("date_calculatedList",date_calculatedList);
	    map.put("numDataList",numDataList);
	    return R.ok().data("map",map);
	}

}
